package speed2010.andreza.vspeed.ontologies;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;

public class Ontology {
	
	private int id;
	private String location;
	private String name;
	private String format;
	private Date creation;
	private Date lastModification;
	private int fileSize;
	private int numberOfConcepts;
	private int numberOfAttributes;
	private int numberOfRelationships;
	private int depth;
	private boolean instances;
	private String idiom;
	protected ArrayList<OntologyConcept> concepts;
		
	public Ontology(int id, String location, String name) throws FileNotFoundException, Exception
	{
		this.id = id;
		this.location = location;
		this.name = name;
		this.setFormat("owl");
		this.concepts = new ArrayList<OntologyConcept>();
		
	}

	public ArrayList<OntologyConcept> getConcepts() {
		return concepts;
	}

	public void setConcepts(ArrayList<OntologyConcept> concepts) {
		this.concepts = concepts;
	}

	@SuppressWarnings("unchecked")
	private void init() throws FileNotFoundException, Exception 
	{
		String fileName = this.location;
		fileName = fileName + "." + this.format;
		//FileInputStream file = new FileInputStream(fileName);
		/*owlModel = ProtegeOWL.createJenaOWLModelFromInputStream(file);
		
		Collection<OWLNamedClass> classes = owlModel.getUserDefinedOWLNamedClasses();
		this.classes = classes;
		Iterator<OWLNamedClass> it = classes.iterator();
		while(it.hasNext())
		{
			this.numberOfConcepts++;
			OWLNamedClass cls = it.next();
			Collection instances = cls.getInstances(false);
			Iterator i = instances.iterator();
			if(!this.instances && i.hasNext())
			{
				this.instances = true;
			}
		}*/
		
		//file.close();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public Date getCreation() {
		return creation;
	}

	public void setCreation(Date creation) {
		this.creation = creation;
	}

	public Date getLastModification() {
		return lastModification;
	}

	public void setLastModification(Date lastModification) {
		this.lastModification = lastModification;
	}

	public int getFileSize() {
		return fileSize;
	}

	public void setFileSize(int fileSize) {
		this.fileSize = fileSize;
	}

	public int getNumberOfConcepts() {
		return this.concepts.size();
	}

	public void setNumberOfConcepts(int numberOfConcepts) {
		this.numberOfConcepts = numberOfConcepts;
	}

	public int getNumberOfAttributes() {
		return numberOfAttributes;
	}

	public void setNumberOfAttributes(int numberOfAttributes) {
		this.numberOfAttributes = numberOfAttributes;
	}

	public int getNumberOfRelationships() {
		return numberOfRelationships;
	}

	public void setNumberOfRelationships(int numberOfRelationships) {
		this.numberOfRelationships = numberOfRelationships;
	}

	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}

	public boolean isInstances() {
		return instances;
	}

	public void setInstances(boolean instances) {
		this.instances = instances;
	}

	public String getIdiom() {
		return idiom;
	}

	public void setIdiom(String idiom) {
		this.idiom = idiom;
	}
	
	/*public Collection getConcepts()
	{
		return this.classes;
	}*/
	
	public boolean equals(Object o)
	{
		return this.id == ((Ontology) o).getId();
	}

}
